package com.chenss.dragonserapp.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chenss.dragonserapp.R;
import com.chenss.dragonserapp.base.BaseAdp;
import com.chenss.dragonserapp.model.GoodsDetailsModel;
import com.chenss.dragonserapp.model.GoodsListModel;

import java.util.List;

public class GoodsDetailsAdapter extends BaseAdp<GoodsDetailsModel.SecurityListBean> {

	private GoodsDetailsAdapterListener listener;

	public GoodsDetailsAdapter(Context ctx, List<GoodsDetailsModel.SecurityListBean> list) {
		super(ctx, list, R.layout.item_goods_details);
	}

	@Override
	public void Convert(final int position, View convertView) {
		// TODO Auto-generated method stub
		TextView tv_name = Get(convertView,R.id.tv_goods_name);
		TextView tv_id = Get(convertView,R.id.tv_goods_id);
		CheckBox checkBox = Get(convertView,R.id.checkbox);
		tv_name.setText( mDataList.get(position).getGoods_name_property());
		tv_id.setText( mDataList.get(position).getSecurity_code_id());

		if (!mDataList.get(position).isSelect()){
			checkBox.setChecked(false);
		}
		checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
			@Override
			public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
				listener.checkChanged(b , position);
			}
		});

	}
	public void setCheckBoxListener(GoodsDetailsAdapterListener listener){
		this.listener = listener;
	}

	public interface GoodsDetailsAdapterListener{

		void checkChanged(boolean b , int position);
	}
}
